<?php
/**
 * $Id: LoginController.php 969 2008-07-29 13:55:14Z pawy $
 * Kontroler autoryzacji
 *
 */
class LoginController  extends MainController implements ControllerInterface {
	/**
	 * domyslna metoda
	 *
	 */
	public function IndexAction($param) {
            
	}

	/**
	 * Autoryzacja
	 *
	 */
	public function AuthAction($param) {

		if(isset($_REQUEST['eLogin']) && isset($_REQUEST['ePassword'])){
			$result = AuthDAL::Login($_REQUEST['eLogin'], $_REQUEST['ePassword']);
                        
			if($result == true){
				//$logger = LoggerManager::getLogger(__CLASS__);
				//$logger->info('Zalogowal sie uzytkownik: '.$_REQUEST['eLogin'].', z ip: '.getenv('REMOTE_ADDR').', z domeny: '.getenv('REMOTE_HOST'));
				Header("Location: ". Router::GenerateUrl() );
			} else {
				$this->smarty->assign("loginError", "1");
			}
		}
	}

	/**
	 * Wylogowanie
	 *
	 */
	public function LogoutAction($param) {
		AuthDAL::Logout();

		die(Header("Location: login".APPLICATION_FILE_TYPE));
	}

	/**
	 * Wspolna metoda
	 *
	 */
	public function preDispatch($param) {
		session_start();
		$template = 'login.tpl';
		Registry::Remove('smartyTemplate');
		Registry::Set('smartyTemplate', $template);
		$this->smarty->assign("loginError", "");
                $this->AddTitle(' ');
            $this->AddDescription(' ');
	}

	public function postDispatch($param)
	{
		
	}
}
?>